const express = require("express");
const server = express();
const formidable = require("formidable");


// 设置上传文件的接受条件
let readFile = formidable({
  uploadDir: __dirname + "/img", //存储文件地址
  maxFieldsSize: 1024 * 1024, //接受图片大小
  keepExtensions: true,
});
// server.use(express.urlencoded({ extended: false }));
server.post("/uploading", (req, res) => {
    // console.log(req.body);
  // 调用readFile方法处理req数据
  readFile.parse(req, (err, fields, files) => {
    if (err) {
      console.log(err);
      return;
    }
    res.send("上传成功");
  });
});

server.listen(80, () => {
  console.log("success");
});
